home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume20 / notation / part03 < prev    next >
Encoding:
Text File  |  1991-06-18  |  56.1 KB  |  2,162 lines

  1. Newsgroups: comp.sources.misc
  2. From: Henry Thomas <hthomas@irisa.fr>
  3. Subject:  v20i054:  notation - chess text handler, Part03/04
  4. Message-ID: <1991Jun17.051633.2730@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: a3727789c93cc51fec0395cd867cf252
  6. Date: Mon, 17 Jun 1991 05:16:33 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Henry Thomas <hthomas@irisa.fr>
  10. Posting-number: Volume 20, Issue 54
  11. Archive-name: notation/part03
  12. Supersedes: notation: Volume 18, Issue 12-14
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 3 (of 4)."
  21. # Contents:  drivers.c lexer.c
  22. # Wrapped by hthomas@cattus on Sun Jun 16 18:17:28 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'drivers.c' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'drivers.c'\"
  26. else
  27. echo shar: Extracting \"'drivers.c'\" \(20041 characters\)
  28. sed "s/^X//" >'drivers.c' <<'END_OF_FILE'
  29. X/*
  30. X  Notation program
  31. X  @(#)drivers.c    3.1 (C) Henry Thomas\tVersion 3.1\tDated 6/16/91
  32. X */
  33. X
  34. X#ifdef __STDC__
  35. X#include <stdlib.h>
  36. X#endif
  37. X#include<stdio.h>
  38. X
  39. X#include <ctype.h>
  40. X#include "chesstype.h"
  41. X#include "notation.h"
  42. X#include "drivers.h"
  43. X
  44. X/* postscript characters translation table
  45. X   one entry per piece
  46. X   each entry has four fields:
  47. X   - white piece on white case
  48. X   - white piece on black case
  49. X   - black piece on ...
  50. X   ..
  51. X */
  52. X#define PSINDEX(a,b) ((((a)==WHITE)?0:2)+(((b)%2)?0:1))
  53. X
  54. Xstatic char * postscript_table[][4] = {
  55. X  { " ", "x",     " ", "x"     }, /* void */
  56. X  { "k", "\\373", "K", "\\360" }, /* king */
  57. X  { "q", "\\317", "Q", "\\316" }, /* queen */
  58. X  { "r", "\\250", "R", "\\345" }, /* rook */
  59. X  { "b", "\\272", "B", "\\365" }, /* bishop */
  60. X  { "n", "\\265", "N", "\\366" }, /* knight */
  61. X  { "p", "\\271", "P", "\\270" }  /* pawn */
  62. X};
  63. X
  64. X/* TeX table for using the chess figure in board design */
  65. Xstatic char * metafont_table[][4] = {
  66. X  /*   W/W      W/B      B/W      B/B */
  67. X  { "\\WWW", "\\DDD", "\\WWW", "\\DDD" }, /* void */
  68. X  { "\\WKW", "\\WKB", "\\BKW", "\\BKB" }, /* king */
  69. X  { "\\WQW", "\\WQB", "\\BQW", "\\BQB" }, /* queen */
  70. X  { "\\WRW", "\\WRB", "\\BRW", "\\BRB" }, /* rook */
  71. X  { "\\WBW", "\\WBB", "\\BBW", "\\BBB" }, /* bishop */
  72. X  { "\\WNW", "\\WNB", "\\BNW", "\\BNB" }, /* knight */
  73. X  { "\\WPW", "\\WPB", "\\BPW", "\\BPB" }  /* pawn */
  74. X};
  75. X
  76. X/* TeX table for using the chess figures in move description */
  77. Xstatic char * latex_table[] = {
  78. X  "\\FigVoid", "\\FigK", "\\FigQ", "\\FigR", "\\FigB", "\\FigN", "\\FigP"
  79. X};
  80. X
  81. X/* various tex symbols */
  82. Xstatic char FigDash[] = "\\FigDash";
  83. Xstatic char FigCapt[] = "\\FigCapt";
  84. Xstatic char FigDots[] = "\\FigDots";
  85. Xstatic char FigDot[] = "\\FigDot";
  86. X
  87. X#define G_ROQUE  "O-O-O" 
  88. X#define P_ROQUE  "O-O" 
  89. X
  90. X/* variation symbols */
  91. Xstatic char varsymb[][2] = { { '[', ']' }, { '(', ')' } };
  92. X
  93. Xstatic char * com_tex[] = {
  94. X#define CHESSSYMB(LET,LASC,SASC,TEX,PS,ENG,FRA) TEX,
  95. X#include "chesssymb.def"
  96. X ""
  97. X };
  98. X#undef CHESSSYMB
  99. X
  100. Xstatic char * com_ps[] = {
  101. X#define CHESSSYMB(LET,LASC,SASC,TEX,PS,ENG,FRA) PS,
  102. X#include "chesssymb.def"
  103. X ""
  104. X };
  105. X#undef CHESSSYMB
  106. X
  107. Xstatic FILE * ftmp ;
  108. X
  109. X
  110. X/* ---------------- output functions ---------------- */
  111. X
  112. X/* convert a roque in term of king's move */
  113. X#ifdef __STDC__
  114. Xstatic int roque_to_move(depl *m)
  115. X#else
  116. Xstatic int roque_to_move(m)
  117. X     depl * m;
  118. X#endif
  119. X{
  120. X
  121. X  m->piece = KING;
  122. X  m->fromcol   = 5;
  123. X  if (m->type == GRANDROQUE)  
  124. X    m->tocol = 3;
  125. X  else
  126. X    m->tocol = 7;
  127. X
  128. X  if (m->whiteturn)
  129. X    m->fromlig = m->tolig = 1;
  130. X  else
  131. X    m->fromlig = m->tolig = 8;
  132. X
  133. X  return(TRUE);
  134. X}
  135. X
  136. X/* (kind of) buffering of output */
  137. X#ifdef __STDC__
  138. Xstatic void init_buffer(format *d, int side)
  139. X#else
  140. Xstatic void init_buffer(d,side)
  141. X     format * d;
  142. X     int side ;
  143. X#endif
  144. X{
  145. X  switch (d->type) {
  146. X  case D_ASCII:
  147. X    if (side != BLACK) (void) sprintf(d->white_buffer,"...");
  148. X    if (side != WHITE) (void) sprintf(d->black_buffer,"   ");
  149. X    break;
  150. X  case D_TEX:
  151. X    if (side != BLACK) (void) sprintf(d->white_buffer,"%s",FigDots);
  152. X    if (side != WHITE) (void) sprintf(d->black_buffer,"~");
  153. X    break;
  154. X  default:
  155. X    if (side != BLACK) d->white_buffer[0] = '\0' ;
  156. X    if (side != WHITE) d->black_buffer[0] = '\0' ;
  157. X    break;
  158. X  }
  159. X}
  160. X
  161. X/* this procedure is responsible for PRINTING the move */
  162. X#ifdef __STDC__
  163. Xstatic void flush_buffer(format *d)
  164. X#else
  165. Xstatic void flush_buffer(d)
  166. X     format * d;
  167. X#endif
  168. X{
  169. X  
  170. X  /* if we have been inteerupted (by a comment, a board display etc...
  171. X     if the move is black
  172. X     we display <movenumber> ... <blackmove>
  173. X     */
  174. X  if ((d->interrupt == TRUE) && (d->iswhiteturn == FALSE)) {
  175. X    switch (d->type) {
  176. X    case D_TEX:
  177. X      (void) fprintf(d->outfile,
  178. X             "\\MoveNumber{%s}\\WhiteMove{%s}\\BlackMove{%s}\n", 
  179. X             d->move_buffer,FigDots,d->black_buffer);
  180. X      break;
  181. X    case D_GNU:
  182. X    case D_XCHESS:
  183. X      /* no special case for GNU */
  184. X      (void) fprintf(d->outfile,"\t%s\n",d->black_buffer);
  185. X      break;    
  186. X    default:
  187. X      (void) fprintf(d->outfile,"\n%3s.%9s%9s", 
  188. X             d->move_buffer,"...",d->black_buffer);
  189. X      break;
  190. X    }
  191. X    d->interrupt = FALSE ;
  192. X  } else {
  193. X  /* else (no interrupt)
  194. X     we display either white or black move 
  195. X     */
  196. X    switch (d->type) {
  197. X    case D_TEX:
  198. X      if (d->iswhiteturn)
  199. X    (void) fprintf(d->outfile,
  200. X               "\\MoveNumber{%s}\\WhiteMove{%s}", d->move_buffer,d->white_buffer);
  201. X      else
  202. X    (void) fprintf(d->outfile,
  203. X               "\\BlackMove{%s}\n",d->black_buffer);
  204. X      break;
  205. X    case D_XCHESS:
  206. X      if (d->iswhiteturn)
  207. X    (void) fprintf(d->outfile,"%3s.", d->move_buffer);
  208. X    case D_GNU:
  209. X      if (d->iswhiteturn)
  210. X    (void) fprintf(d->outfile,"\t%s",d-> white_buffer);
  211. X      else
  212. X    (void) fprintf(d->outfile,"\t%s\n",d->black_buffer);
  213. X      break;    
  214. X    default:
  215. X      if (d->iswhiteturn)
  216. X    (void) fprintf(d->outfile,"\n%3s.%9s", d->move_buffer,d->white_buffer);
  217. X      else
  218. X    (void) fprintf(d->outfile,"%9s", d->black_buffer);
  219. X      break;
  220. X    }
  221. X  } /* end printing */
  222. X
  223. X  /* reset buffer */
  224. X  if (! d->iswhiteturn)
  225. X    init_buffer(d,VOID);
  226. X  d->interrupt = FALSE;
  227. X}
  228. X
  229. X/* a generic parametrised driver for move output
  230. X   */
  231. X#ifdef __STDC__
  232. Xstatic void output_move_generic(format *dr, depl *d)
  233. X#else
  234. Xstatic void output_move_generic(dr,d)
  235. X     format * dr;
  236. X     depl *d;
  237. X#endif
  238. X{
  239. X  char ligne[128] ;
  240. X  char themove[128] ;
  241. X  char thepiece[16]  ;
  242. X  char debcol[16];
  243. X  char frommove[16]  ;
  244. X  char tomove[16] ;
  245. X  char captsymb[16] ;
  246. X  char lie[16] ;
  247. X  char prom[16];
  248. X
  249. X  int ambigue = FALSE ;
  250. X
  251. X  ligne[0] = themove[0] = thepiece[0] = debcol[0]  = '\0';
  252. X  frommove[0] = tomove[0] = lie[0] = prom[0] = '\0' ;
  253. X
  254. X  if (dr->type == D_TEX) 
  255. X    (void) sprintf(captsymb,"{%s}", FigCapt);
  256. X  else
  257. X    (void) sprintf(captsymb,"%s", "x" );
  258. X
  259. X  if (dr->type == D_TEX) {
  260. X    if (dr->variation == 0)
  261. X      (void) sprintf (dr->move_buffer,"{\\bf %d\\FigDot}",d->move);
  262. X    else 
  263. X      (void) sprintf (dr->move_buffer,"{%d\\FigDot}",d->move);
  264. X  } else 
  265. X    (void) sprintf (dr->move_buffer,"%d",d->move);
  266. X
  267. X  if ((d->type == PETITROQUE) && !dr->roque_alg)
  268. X    (void) sprintf (themove,"%s",P_ROQUE);
  269. X  if ((d->type == GRANDROQUE) && !dr->roque_alg)
  270. X    (void) sprintf (themove,"%s",G_ROQUE);
  271. X  if (dr->roque_alg && 
  272. X      ((d->type == GRANDROQUE) || (d->type == PETITROQUE)))
  273. X    (void) roque_to_move(d);
  274. X
  275. X  if (dr-> roque_alg || 
  276. X      ((d->type != GRANDROQUE) && (d->type != PETITROQUE))) {
  277. X
  278. X    /* we check here for ambiguous move */
  279. X    if ((d->type != GRANDROQUE) && (d->type != PETITROQUE)) {
  280. X      ambigue = ambiguity (d->piece, d->tolig,d->tocol);
  281. X      /* if ( (ambigue ) && (d->piece != PAWN ))
  282. X       * (void) fprintf (stderr,"ambiguity at move %d",tos->move);
  283. X       */
  284. X    }
  285. X    themove[0] = '\0' ;
  286. X    if ((dr->output_move_format == SHORTENED) 
  287. X    && (d->type == PRISE) && (d->piece == PAWN))
  288. X      (void) sprintf (debcol, "%c",coltoletter(d->fromcol));
  289. X
  290. X    if (dr->print_piece)
  291. X      if (d->piece != PAWN || dr->print_pawn) {
  292. X    if (dr->type == D_TEX )
  293. X      (void) sprintf(thepiece,"%s ",latex_table[d->piece]);
  294. X    else
  295. X      (void) sprintf(thepiece,"%c",dr->out_table[d->piece]);
  296. X      }
  297. X
  298. X    if ((dr->output_move_format == ALGEBRAIC))
  299. X      (void)sprintf(frommove,"%c%c",
  300. X            coltoletter(d->fromcol),ligtoletter(d->fromlig));
  301. X    if ( ambigue && dr->print_liaison ) {
  302. X      (void) sprintf(lie,"-");
  303. X      (void)sprintf(frommove,"%c%c",
  304. X            coltoletter(d->fromcol),ligtoletter(d->fromlig));
  305. X      debcol[0] = '\0' ;
  306. X    }
  307. X    if (d->promotion) {
  308. X      if (dr->print_piece) {
  309. X    if (dr->type == D_TEX )
  310. X      (void) sprintf(prom,"=%s ",latex_table[d->promotion]);
  311. X      else
  312. X        (void) sprintf(prom,"=%c",dr->out_table[d->promotion]);
  313. X      }
  314. X    }
  315. X          
  316. X    if (dr->print_liaison) {
  317. X      if ((d->type == PRISE) || (d->type == PROM_ET_PRISE) 
  318. X      || (d->type == EN_PASSANT) )
  319. X    (void) sprintf(lie,"%s",captsymb);
  320. X      else
  321. X    if ((dr->output_move_format == ALGEBRAIC))
  322. X      (void) sprintf(lie,"%c",'-');
  323. X    }
  324. X    
  325. X    (void) sprintf(tomove,"%c%c",coltoletter(d->tocol),ligtoletter(d->tolig));
  326. X
  327. X    (void) sprintf (themove,"%s%s%s%s%s%s",
  328. X            thepiece,debcol,frommove,lie, tomove,prom);
  329. X  }
  330. X
  331. X  if (d->whiteturn)
  332. X    (void) sprintf (dr->white_buffer, "%s",themove);
  333. X  else
  334. X    (void) sprintf (dr->black_buffer, "%s",themove);
  335. X
  336. X  dr->iswhiteturn = d->whiteturn; 
  337. X
  338. X  /*fprintf(dr->outfile, "=%d=%d= ",d->move,d->whiteturn);*/
  339. X  flush_buffer(dr); 
  340. X}
  341. X
  342. X/* variation handler */
  343. X#ifdef __STDC__
  344. Xstatic void output_variation_generic (format *dr, int inout)
  345. X#else
  346. Xstatic void output_variation_generic (dr,inout)
  347. X     format * dr;
  348. X     int inout;
  349. X#endif
  350. X{
  351. X  char symbol;
  352. X
  353. X  if (dr->variation > 1)
  354. X    symbol = varsymb[1][inout];
  355. X  else
  356. X    symbol = varsymb[0][inout];
  357. X    
  358. X  switch (dr->type) {
  359. X  case D_TEX:
  360. X    /* we must boldface the brackets for level 1 */
  361. X    if (dr->variation == 1 ) {
  362. X      (void) fprintf(dr->outfile, " {\\bf %c} ",symbol);
  363. X      if (inout == 0 )
  364. X    (void) fprintf(dr->outfile, "\\VariationLine");
  365. X      else
  366. X    (void) fprintf(dr->outfile, "\\MainLine");
  367. X    } else
  368. X      (void) fprintf(dr->outfile, " %c ",symbol);
  369. X    break;
  370. X  default:
  371. X    (void) fprintf(dr->outfile, "  %c",symbol);
  372. X    break;
  373. X  };
  374. X}
  375. X
  376. X#ifdef __STDC__
  377. Xstatic void output_text_generic(format *dr, int type, char *string, int code)
  378. X#else
  379. Xstatic void output_text_generic(dr, type, string, code)
  380. X     format *dr ;
  381. X     int type;
  382. X     char * string;
  383. X     int code;
  384. X#endif
  385. X{
  386. X  switch (type) {
  387. X  case T_COMMENT:
  388. X    if (com_short[code] != '\0' )
  389. X      (void) fprintf(dr->outfile," %s ",com_short[code]);
  390. X    else
  391. X      (void) fprintf(dr->outfile," %s ",com_long[code]);
  392. X      break;
  393. X  case T_TEXT:
  394. X    (void) fprintf(dr->outfile," %s ",string);
  395. X    break;
  396. X  case T_TITLE:
  397. X    (void) fprintf(dr->outfile,"\n  %s\n",string);
  398. X    break;
  399. X  case T_SUBTITLE:
  400. X    (void) fprintf(dr->outfile,"    %s\n",string);
  401. X    break;
  402. X  case T_SCORE:
  403. X    (void) fprintf(dr->outfile,"  %s\n",string);
  404. X  default:
  405. X    break;
  406. X  }
  407. X}
  408. X
  409. X
  410. X/* ---------------- ascii driver ----------  */
  411. X#ifdef __STDC__
  412. Xstatic void output_init_ascii(format *dr) 
  413. X#else
  414. Xstatic void output_init_ascii(dr) 
  415. Xformat *dr;
  416. X#endif
  417. X{}
  418. X    
  419. X#ifdef __STDC__
  420. Xstatic void output_board_ascii(format *dr,game *g)
  421. X#else
  422. Xstatic void output_board_ascii(dr,g)
  423. X     format * dr;
  424. X     game * g;
  425. X#endif
  426. X{
  427. X  register int i,j;
  428. X
  429. X  dr->interrupt = TRUE;
  430. X
  431. X  (void) fprintf(dr->outfile,"\n\n");
  432. X  for (i=8 ; i >=1 ; i--) {
  433. X    if (dr->coordinates)
  434. X      (void) fprintf(dr->outfile,"%d ",i);
  435. X    (void) fputc('|',dr->outfile);
  436. X    for (j=1 ; j<9 ; j++) {
  437. X      if (g->board[i][j] != VOID) {
  438. X    if (g->color[i][j] == WHITE) 
  439. X     (void) fputc(dr->out_table[g->board[i][j]], dr->outfile);
  440. X    else 
  441. X      (void) fputc(tolower(dr->out_table[g->board[i][j]]),dr->outfile);
  442. X      } else
  443. X    (void) fputc ( ((i+j)% 2)?' ':'/', dr->outfile);
  444. X      (void) fputc('|', dr->outfile);
  445. X    }
  446. X    (void) fputc('\n', dr->outfile);
  447. X  }
  448. X  if (dr->coordinates)
  449. X    (void) fprintf(dr->outfile,"   a b c d e f g h\n");
  450. X  (void) fprintf(dr->outfile,"\n");
  451. X}
  452. X
  453. X/* ---------------- postscript --------- */
  454. X
  455. X#ifdef __STDC__
  456. Xstatic void output_board_ps(format *dr,game *g)
  457. X#else
  458. Xstatic void output_board_ps(dr,g)
  459. X     format *dr;
  460. X     game * g;
  461. X#endif
  462. X{
  463. X  register int i,j;
  464. X  register int c;
  465. X  char chaine[MAXTOKLEN];
  466. X
  467. X  /* header file */
  468. X  (void) strcpy(chaine,LIB_DIR);
  469. X  if ((ftmp = fopen(strcat(chaine,PS_HEADER),"r")) == NULL)
  470. X    message((stderr,"Can't open ps header file.\n"));
  471. X  else {
  472. X    while ((c = getc(ftmp)) != EOF)
  473. X      (void) fputc(c,dr->outfile);
  474. X    (void) fclose(ftmp);
  475. X  }
  476. X
  477. X  (void) fprintf(dr->outfile,"( ________) 72 714 T\n");
  478. X  for (i=8 ; i >=1 ; i--) {
  479. X    (void) fprintf(dr->outfile,"(/");
  480. X    for (j=1 ; j<9 ; j++) {
  481. X    (void) fprintf(dr->outfile,"%s",
  482. X           postscript_table[g->board[i][j]][PSINDEX(g->color[i][j],(i+j))]);
  483. X    }
  484. X    (void) fprintf(dr->outfile,"\\\\) 72 %d T\n",474 + (i-1)*30);
  485. X  }
  486. X  (void) fprintf(dr->outfile,"( --------) 72 444 T\n");
  487. X
  488. X  /* footer file */
  489. X  (void) strcpy(chaine,LIB_DIR);
  490. X  if ((ftmp = fopen(strcat(chaine,PS_FOOTER),"r")) == NULL)
  491. X    message((stderr,"Can't open ps footer file.\n"));
  492. X  else {
  493. X    while ((c = getc(ftmp)) != EOF)
  494. X      (void) fputc(c,dr->outfile);
  495. X    (void) fclose(ftmp);
  496. X  }
  497. X}
  498. X
  499. X/* ---------------- nroff --------------- */
  500. X#ifdef __STDC__
  501. Xstatic void output_init_roff(format *dr)
  502. X#else
  503. Xstatic void output_init_roff(dr)
  504. X     format *dr;
  505. X#endif
  506. X{
  507. X}
  508. X
  509. X#ifdef __STDC__
  510. Xstatic void output_board_roff(format *dr,game *g)
  511. X#else
  512. Xstatic void output_board_roff(dr, g)
  513. X     format *dr;
  514. X     game * g;
  515. X#endif
  516. X{
  517. X  register int i,j;
  518. X
  519. X  dr->interrupt = TRUE;
  520. X
  521. X  (void) fprintf(dr->outfile,".br\n");
  522. X  for (i=8 ; i >=1 ; i--) {
  523. X    (void) fprintf(dr->outfile,".ce\n  ");
  524. X    for (j=1 ; j<9 ; j++) {
  525. X      if (g->board[i][j] != VOID) {
  526. X    if (g->color[i][j] == WHITE) 
  527. X     (void) fputc(dr->out_table[g->board[i][j]], dr->outfile);
  528. X    else 
  529. X      (void) fputc(tolower(dr->out_table[g->board[i][j]]),dr->outfile);
  530. X      } else
  531. X    /*(void) fputc ( ((i+j)% 2)?' ':'/', dr->outfile);*/
  532. X    (void) fprintf(dr->outfile,".");
  533. X    }
  534. X    (void) fprintf(dr->outfile,"\n.br\n");
  535. X  }
  536. X  (void) fprintf(dr->outfile,"\n");
  537. X}
  538. X
  539. X/* ---------------- tex -------------------- */
  540. X#ifdef __STDC__
  541. Xstatic void output_init_tex(format *dr)
  542. X#else
  543. Xstatic void output_init_tex(dr)
  544. X     format *dr;
  545. X#endif
  546. X{
  547. X  register int c;
  548. X  char chaine[MAXTOKLEN];
  549. X
  550. X  /* header file */
  551. X  (void) strcpy(chaine,LIB_DIR);
  552. X  if ((ftmp = fopen(strcat(chaine,TEX_HEADER),"r")) == NULL)
  553. X    message((stderr,"Can't open tex header file.\n"));
  554. X  else {
  555. X    while ((c = getc(ftmp)) != EOF)
  556. X      (void) fputc(c,dr->outfile);
  557. X    (void) fclose(ftmp);
  558. X  }
  559. X}
  560. X
  561. X#ifdef __STDC__
  562. Xstatic void output_text_tex(format *dr, int type, char * string, int code)
  563. X#else
  564. Xstatic void output_text_tex(dr, type, string, code)
  565. X     format *dr ;
  566. X     int type;
  567. X     char * string;
  568. X     int code;
  569. X#endif
  570. X{
  571. X  switch (type) {
  572. X  case T_COMMENT:
  573. X    if (com_tex[code] != '\0' )
  574. X      (void) fprintf(dr->outfile,"%s\\ ",com_tex[code]);
  575. X    else
  576. X      (void) fprintf(dr->outfile,"%s\\ ",com_short[code]);
  577. X      break;
  578. X  case T_TEXT:
  579. X    (void) fprintf(dr->outfile," %s \n",string);
  580. X    break;
  581. X  case T_TITLE:
  582. X    (void) fprintf(dr->outfile,"\\ChessTitle{%s}\n",string);
  583. X    break;
  584. X  case T_SUBTITLE:
  585. X    (void) fprintf(dr->outfile,"\\ChessSubTitle{%s}\n",string);
  586. X    break;
  587. X  case T_SCORE:
  588. X    (void) fprintf(dr->outfile,"\\ChessScore{%s}\n",string);
  589. X  default:
  590. X    break;
  591. X  };
  592. X}
  593. X
  594. X#ifdef __STDC__
  595. Xstatic void output_board_tex(format *dr,game *g)
  596. X#else
  597. Xstatic void output_board_tex(dr,g)
  598. X     format *dr;
  599. X     game * g;
  600. X#endif
  601. X{
  602. X  register int i,j;
  603. X
  604. X  dr->interrupt = TRUE;
  605. X
  606. X  (void) fprintf(dr->outfile,"\n\n");
  607. X  (void)fprintf(dr->outfile,"$$\\vbox{\\bigskip\\offinterlineskip\\tabskip=0pt\n");
  608. X  (void) fprintf(dr->outfile,"\\halign{#\\vvrule &#&#&#&#&#&#&#&#&#\\vvrule \\cr\n");
  609. X  (void) fprintf(dr->outfile,"\\noalign{\\hhrule}\n");
  610. X  for (i=8 ; i >=1 ; i--) {
  611. X    (void) fprintf(dr->outfile,"&");
  612. X    for (j=1 ; j < 9 ; j++) {
  613. X    (void) fprintf(dr->outfile,"%s",
  614. X           metafont_table[g->board[i][j]][PSINDEX(g->color[i][j],(i+j))]);
  615. X      (void) fprintf(dr->outfile,"&");
  616. X    }
  617. X    (void) fprintf(dr->outfile,"\\cr \n");
  618. X  }
  619. X  (void) fprintf(dr->outfile,"\\noalign{\\hhrule}}}$$");
  620. X  (void) fprintf(dr->outfile,"");
  621. X  (void) fprintf(dr->outfile,"\n\n");
  622. X}
  623. X
  624. X#ifdef __STDC__
  625. Xstatic void output_end_tex(format *dr)
  626. X#else
  627. Xstatic void output_end_tex(dr)
  628. X     format *dr;
  629. X#endif
  630. X{ 
  631. X  (void) fprintf(dr->outfile, "~\n\n\n\\end{document}\n");
  632. X}
  633. X
  634. X/* ------------------ gnu - xchess ---------- */
  635. X
  636. X#ifdef __STDC__
  637. Xstatic void output_init_gnu(format *dr)
  638. X#else
  639. Xstatic void output_init_gnu(dr)
  640. X     format *dr;
  641. X#endif
  642. X{
  643. X  (void) fprintf(dr->outfile, "X Chess -- Mon Dec 10 11:47:18 MET 1990\n");
  644. X  (void) fprintf(dr->outfile,"\tGame played on dumbkopft.irisa.fr:0.0\n");
  645. X  (void) fprintf(dr->outfile,"\talgebraic\n");
  646. X}
  647. X
  648. X/* ---------------- driver handler ---------- */
  649. X/* dummy driver */
  650. X#ifdef __STDC__
  651. Xstatic void null_driver(void) {}
  652. X#else
  653. Xstatic void null_driver() {}
  654. X#endif
  655. X
  656. X/* the drivers */
  657. X#ifdef __STDC__
  658. Xvoid output_init(format *dr)
  659. X#else
  660. Xvoid output_init(dr)
  661. X     format *dr ;
  662. X#endif
  663. X{
  664. X  if (dr->print_headers)
  665. X    dr->out_init(dr);
  666. X}
  667. X
  668. X#ifdef __STDC__
  669. Xvoid output_move(format *dr,depl *d)
  670. X#else
  671. Xvoid output_move(dr,d)
  672. X     format *dr ;
  673. X     depl *d;
  674. X#endif
  675. X{
  676. X  if (! (((dr->type == D_GNU) || (dr->type == D_XCHESS))
  677. X    && (dr->variation > 0)))
  678. X    dr->out_move(dr,d);
  679. X}
  680. X
  681. X#ifdef __STDC__
  682. Xvoid output_variation(format *dr, int inout)
  683. X#else
  684. Xvoid output_variation(dr, inout)
  685. X     format *dr ;
  686. X     int inout;
  687. X#endif
  688. X{
  689. X  dr->out_variation(dr,inout);
  690. X}
  691. X
  692. X#ifdef __STDC__
  693. Xvoid output_text(format *dr, int type, char *string, int code)
  694. X#else
  695. Xvoid output_text(dr, type, string, code)
  696. X     format *dr ;
  697. X     int type;
  698. X     char * string;
  699. X     int code;
  700. X#endif
  701. X{
  702. X  if ((dr->type != D_GNU) && (dr->type != D_XCHESS))
  703. X    dr->out_text(dr, type, string, code);
  704. X}
  705. X
  706. X#ifdef __STDC__
  707. Xvoid output_board(format *dr, game *g)
  708. X#else
  709. Xvoid output_board(dr,g)
  710. X     format *dr ;
  711. X     game *g ;
  712. X#endif
  713. X{
  714. X  dr->out_board(dr,g);
  715. X}
  716. X
  717. X#ifdef __STDC__
  718. Xvoid output_end(format *dr)
  719. X#else
  720. Xvoid output_end(dr)
  721. X     format *dr ;
  722. X#endif
  723. X{
  724. X  if (dr->print_headers)
  725. X    dr->out_end(dr);
  726. X  (void) fprintf(dr->outfile,"\n");
  727. X}
  728. X
  729. X
  730. X#ifdef __STDC__
  731. Xformat * new_driver(void)
  732. X#else
  733. Xformat * new_driver()
  734. X#endif
  735. X{
  736. X  format * tmp;
  737. X  int i; 
  738. X
  739. X  tmp = (format *) malloc (sizeof(format));
  740. X  ALLOCP(tmp);
  741. X  for (i=0; i < ((sizeof (format))/ sizeof (int)) ; i++)
  742. X    ((int *) tmp)[i] = 0;
  743. X  tmp->output_move_format = SHORTENED;
  744. X  tmp->print_headers = TRUE;
  745. X  return(tmp);
  746. X}
  747. X
  748. X#ifdef __STDC__
  749. Xvoid init_driver(format *dr,int driver)
  750. X#else
  751. Xvoid init_driver(dr,driver)
  752. X     format * dr;
  753. X     int driver;
  754. X#endif
  755. X{
  756. X  dr->type = driver ;
  757. X
  758. X  init_buffer(dr, VOID);
  759. X  switch (dr->type) {
  760. X  case D_ASCII:
  761. X    dr->print_move = TRUE;
  762. X    dr->print_piece = TRUE;
  763. X    dr->print_pawn = FALSE;
  764. X    dr->roque_alg = FALSE;
  765. X    dr->print_liaison = TRUE;
  766. X    dr->out_init = output_init_ascii;
  767. X    dr->out_move = output_move_generic;
  768. X    dr->out_variation = output_variation_generic;
  769. X    dr->out_text = output_text_generic;
  770. X    dr->out_board = output_board_ascii;
  771. X    dr->out_end = null_driver;
  772. X    break;
  773. X  case D_POST:
  774. X    dr->out_init = null_driver;
  775. X    dr->out_move = null_driver;
  776. X    dr->out_variation = null_driver;
  777. X    dr->out_text = null_driver;
  778. X    dr->out_board = output_board_ps;
  779. X    dr->out_end = null_driver;
  780. X    break;
  781. X  case D_TEX:
  782. X    dr->print_move = TRUE;
  783. X    dr->print_piece = TRUE;
  784. X    dr->print_pawn = FALSE;
  785. X    dr->roque_alg = FALSE;
  786. X    dr->print_liaison = TRUE;
  787. X    dr->out_init = output_init_tex;
  788. X    dr->out_move = output_move_generic;
  789. X    dr->out_variation = output_variation_generic;
  790. X    dr->out_text = output_text_tex;
  791. X    dr->out_board = output_board_tex;
  792. X    dr->out_end = output_end_tex;
  793. X    break;
  794. X  case D_ROFF:
  795. X    dr->print_move = TRUE;
  796. X    dr->print_piece = TRUE;
  797. X    dr->print_pawn = FALSE;
  798. X    dr->roque_alg = FALSE;
  799. X    dr->print_liaison = TRUE;
  800. X    dr->out_init = output_init_roff;
  801. X    dr->out_move = output_move_generic;
  802. X    dr->out_variation = output_variation_generic;
  803. X    dr->out_text = output_text_generic;
  804. X    dr->out_board = output_board_roff;
  805. X    dr->out_end = null_driver;
  806. X    break;
  807. X  case D_XCHESS:
  808. X    dr->output_move_format = ALGEBRAIC;
  809. X    dr->print_move = TRUE;
  810. X    dr->print_piece = FALSE;
  811. X    dr->print_pawn = FALSE;
  812. X    dr->roque_alg = TRUE;
  813. X    dr->print_liaison = FALSE;
  814. X    dr->out_init = output_init_gnu;
  815. X    dr->out_move = output_move_generic;
  816. X    dr->out_variation = null_driver;
  817. X    dr->out_text = null_driver;
  818. X    dr->out_board = null_driver;
  819. X    dr->out_end = null_driver;
  820. X    break;
  821. X  case D_GNU:
  822. X    dr->output_move_format = ALGEBRAIC;
  823. X    dr->print_move = FALSE;
  824. X    dr->print_piece = FALSE;
  825. X    dr->print_pawn = FALSE;
  826. X    dr->roque_alg = TRUE;
  827. X    dr->print_liaison = FALSE;
  828. X    dr->out_init = null_driver;
  829. X    dr->out_move = output_move_generic;
  830. X    dr->out_variation = null_driver;
  831. X    dr->out_text = null_driver;
  832. X    dr->out_board = null_driver;
  833. X    dr->out_end = null_driver;
  834. X    break;
  835. X  default:
  836. X    error((stderr,"unknown driver"));
  837. X    break;
  838. X  }
  839. X  if (dr->only_board)
  840. X    dr->out_move = null_driver ;
  841. X
  842. X  dr->variation = 0;
  843. X  dr->iswhiteturn = FALSE ;
  844. X  dr->interrupt = FALSE;
  845. X}
  846. END_OF_FILE
  847. if test 20041 -ne `wc -c <'drivers.c'`; then
  848.     echo shar: \"'drivers.c'\" unpacked with wrong size!
  849. fi
  850. # end of 'drivers.c'
  851. fi
  852. if test -f 'lexer.c' -a "${1}" != "-c" ; then 
  853.   echo shar: Will not clobber existing file \"'lexer.c'\"
  854. else
  855. echo shar: Extracting \"'lexer.c'\" \(32637 characters\)
  856. sed "s/^X//" >'lexer.c' <<'END_OF_FILE'
  857. X/* A lexical scanner generated by flex */
  858. X
  859. X/* scanner skeleton version:
  860. X * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  861. X */
  862. X
  863. X#define FLEX_SCANNER
  864. X
  865. X#include <stdio.h>
  866. X
  867. X
  868. X/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  869. X#ifdef c_plusplus
  870. X#ifndef __cplusplus
  871. X#define __cplusplus
  872. X#endif
  873. X#endif
  874. X
  875. X
  876. X#ifdef __cplusplus
  877. X
  878. X#include <stdlib.h>
  879. X#include <osfcn.h>
  880. X
  881. X/* use prototypes in function declarations */
  882. X#define YY_USE_PROTOS
  883. X
  884. X/* the "const" storage-class-modifier is valid */
  885. X#define YY_USE_CONST
  886. X
  887. X#else    /* ! __cplusplus */
  888. X
  889. X#ifdef __STDC__
  890. X
  891. X#ifdef __GNUC__
  892. X#include <stddef.h>
  893. Xvoid *malloc( size_t );
  894. Xvoid free( void* );
  895. X#else
  896. X#include <stdlib.h>
  897. X#endif    /* __GNUC__ */
  898. X
  899. X#define YY_USE_PROTOS
  900. X#define YY_USE_CONST
  901. X
  902. X#endif    /* __STDC__ */
  903. X#endif    /* ! __cplusplus */
  904. X
  905. X
  906. X#ifdef __TURBOC__
  907. X#define YY_USE_CONST
  908. X#endif
  909. X
  910. X
  911. X#ifndef YY_USE_CONST
  912. X#define const
  913. X#endif
  914. X
  915. X
  916. X#ifdef YY_USE_PROTOS
  917. X#define YY_PROTO(proto) proto
  918. X#else
  919. X#define YY_PROTO(proto) ()
  920. X/* we can't get here if it's an ANSI C compiler, or a C++ compiler,
  921. X * so it's got to be a K&R compiler, and therefore there's no standard
  922. X * place from which to include these definitions
  923. X */
  924. Xchar *malloc();
  925. Xint free();
  926. Xint read();
  927. X#endif
  928. X
  929. X
  930. X/* amount of stuff to slurp up with each read */
  931. X#ifndef YY_READ_BUF_SIZE
  932. X#define YY_READ_BUF_SIZE 8192
  933. X#endif
  934. X
  935. X/* returned upon end-of-file */
  936. X#define YY_END_TOK 0
  937. X
  938. X/* copy whatever the last rule matched to the standard output */
  939. X
  940. X/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  941. X/* this used to be an fputs(), but since the string might contain NUL's,
  942. X * we now use fwrite()
  943. X */
  944. X#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  945. X
  946. X/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  947. X * is returned in "result".
  948. X */
  949. X#define YY_INPUT(buf,result,max_size) \
  950. X    if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  951. X        YY_FATAL_ERROR( "read() in flex scanner failed" );
  952. X#define YY_NULL 0
  953. X
  954. X/* no semi-colon after return; correct usage is to write "yyterminate();" -
  955. X * we don't want an extra ';' after the "return" because that will cause
  956. X * some compilers to complain about unreachable statements.
  957. X */
  958. X#define yyterminate() return ( YY_NULL )
  959. X
  960. X/* report a fatal error */
  961. X
  962. X/* The funky do-while is used to turn this macro definition into
  963. X * a single C statement (which needs a semi-colon terminator).
  964. X * This avoids problems with code like:
  965. X *
  966. X *     if ( something_happens )
  967. X *        YY_FATAL_ERROR( "oops, the something happened" );
  968. X *    else
  969. X *        everything_okay();
  970. X *
  971. X * Prior to using the do-while the compiler would get upset at the
  972. X * "else" because it interpreted the "if" statement as being all
  973. X * done when it reached the ';' after the YY_FATAL_ERROR() call.
  974. X */
  975. X
  976. X#define YY_FATAL_ERROR(msg) \
  977. X    do \
  978. X        { \
  979. X        (void) fputs( msg, stderr ); \
  980. X        (void) putc( '\n', stderr ); \
  981. X        exit( 1 ); \
  982. X        } \
  983. X    while ( 0 )
  984. X
  985. X/* default yywrap function - always treat EOF as an EOF */
  986. X#define yywrap() 1
  987. X
  988. X/* enter a start condition.  This macro really ought to take a parameter,
  989. X * but we do it the disgusting crufty way forced on us by the ()-less
  990. X * definition of BEGIN
  991. X */
  992. X#define BEGIN yy_start = 1 + 2 *
  993. X
  994. X/* action number for EOF rule of a given start state */
  995. X#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  996. X
  997. X/* special action meaning "start processing a new file" */
  998. X#define YY_NEW_FILE \
  999. X    do \
  1000. X        { \
  1001. X        yy_init_buffer( yy_current_buffer, yyin ); \
  1002. X        yy_load_buffer_state(); \
  1003. X        } \
  1004. X    while ( 0 )
  1005. X
  1006. X/* default declaration of generated scanner - a define so the user can
  1007. X * easily add parameters
  1008. X */
  1009. X#define YY_DECL int yylex YY_PROTO(( void )) 
  1010. X
  1011. X/* code executed at the end of each rule */
  1012. X#define YY_BREAK break;
  1013. X
  1014. X#define YY_END_OF_BUFFER_CHAR 0
  1015. X
  1016. X#ifndef YY_BUF_SIZE
  1017. X#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  1018. X#endif
  1019. X
  1020. Xtypedef struct yy_buffer_state *YY_BUFFER_STATE;
  1021. X
  1022. X#define YY_CHAR char
  1023. X# line 1 "lexer.l"
  1024. X#define INITIAL 0
  1025. X/* DO NOT REMOVE THIS LINE                      */
  1026. X/*                                              */
  1027. X/* Notation program                             */
  1028. X/* @(#)lexer.l    3.1 (C) Henry Thomas\tVersion 3.1\tDated 6/16/91 */
  1029. X/*                                              */
  1030. X# line 7 "lexer.l"
  1031. X#include <stdio.h>
  1032. X
  1033. X#include "chesstype.h"
  1034. X#include"notation.h"
  1035. X
  1036. X#define NCURLINE 1024
  1037. Xchar curline [NCURLINE] ;
  1038. X
  1039. X#define LARGE_BUF 4096
  1040. Xstatic char commbuf[LARGE_BUF];
  1041. X
  1042. Xint column = 0;
  1043. Xint lineno = 1;
  1044. X
  1045. X#ifdef __STDC__
  1046. Xextern void count(void);
  1047. Xextern char * comment(int closing);
  1048. X#else
  1049. Xextern void count();
  1050. Xextern char * comment();
  1051. X#endif
  1052. X
  1053. X# line 34 "lexer.l"
  1054. X
  1055. X/* done after the current pattern has been matched and before the
  1056. X * corresponding action - sets up yytext
  1057. X */
  1058. X#define YY_DO_BEFORE_ACTION \
  1059. X    yytext = yy_bp; \
  1060. X    yyleng = yy_cp - yy_bp; \
  1061. X    yy_hold_char = *yy_cp; \
  1062. X    *yy_cp = '\0'; \
  1063. X    yy_c_buf_p = yy_cp;
  1064. X
  1065. X#define EOB_ACT_CONTINUE_SCAN 0
  1066. X#define EOB_ACT_END_OF_FILE 1
  1067. X#define EOB_ACT_LAST_MATCH 2
  1068. X
  1069. X/* return all but the first 'n' matched characters back to the input stream */
  1070. X#define yyless(n) \
  1071. X    do \
  1072. X        { \
  1073. X        /* undo effects of setting up yytext */ \
  1074. X        *yy_cp = yy_hold_char; \
  1075. X        yy_c_buf_p = yy_cp = yy_bp + n; \
  1076. X        YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  1077. X        } \
  1078. X    while ( 0 )
  1079. X
  1080. X#define unput(c) yyunput( c, yytext )
  1081. X
  1082. X
  1083. Xstruct yy_buffer_state
  1084. X    {
  1085. X    FILE *yy_input_file;
  1086. X
  1087. X    YY_CHAR *yy_ch_buf;        /* input buffer */
  1088. X    YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  1089. X
  1090. X    /* size of input buffer in bytes, not including room for EOB characters*/
  1091. X    int yy_buf_size;    
  1092. X
  1093. X    /* number of characters read into yy_ch_buf, not including EOB characters */
  1094. X    int yy_n_chars;
  1095. X
  1096. X    int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  1097. X#define EOF_NOT_SEEN 0
  1098. X    /* "pending" happens when the EOF has been seen but there's still
  1099. X     * some text process
  1100. X     */
  1101. X#define EOF_PENDING 1
  1102. X#define EOF_DONE 2
  1103. X    };
  1104. X
  1105. Xstatic YY_BUFFER_STATE yy_current_buffer;
  1106. X
  1107. X/* we provide macros for accessing buffer states in case in the
  1108. X * future we want to put the buffer states in a more general
  1109. X * "scanner state"
  1110. X */
  1111. X#define YY_CURRENT_BUFFER yy_current_buffer
  1112. X
  1113. X
  1114. X/* yy_hold_char holds the character lost when yytext is formed */
  1115. Xstatic YY_CHAR yy_hold_char;
  1116. X
  1117. Xstatic int yy_n_chars;        /* number of characters read into yy_ch_buf */
  1118. X
  1119. X
  1120. X
  1121. X#ifndef YY_USER_ACTION
  1122. X#define YY_USER_ACTION
  1123. X#endif
  1124. X
  1125. X#ifndef YY_USER_INIT
  1126. X#define YY_USER_INIT
  1127. X#endif
  1128. X
  1129. Xextern YY_CHAR *yytext;
  1130. Xextern int yyleng;
  1131. Xextern FILE *yyin, *yyout;
  1132. X
  1133. XYY_CHAR *yytext;
  1134. Xint yyleng;
  1135. X
  1136. XFILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  1137. X
  1138. X#define YY_END_OF_BUFFER 32
  1139. Xtypedef int yy_state_type;
  1140. Xstatic const short int yy_accept[80] =
  1141. X    {   0,
  1142. X        0,    0,   32,   30,   29,   29,    8,    7,   30,    7,
  1143. X       25,   28,    7,    2,    2,   30,   30,   30,   30,   24,
  1144. X       30,   30,   30,   30,   26,   27,    6,    5,    5,    0,
  1145. X       13,    0,    0,    0,    0,    0,    2,    1,    2,    1,
  1146. X       18,   23,    0,    0,    0,    0,    1,    0,   14,    3,
  1147. X        0,    0,   20,    0,    0,    0,    1,    4,    0,   10,
  1148. X        9,   11,    3,    0,    1,    1,   22,    1,    0,    1,
  1149. X       12,    0,   19,    0,   17,   21,   20,   15,    0
  1150. X    } ;
  1151. X
  1152. Xstatic const YY_CHAR yy_ec[128] =
  1153. X    {   0,
  1154. X        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  1155. X        2,    2,    1,    1,    1,    1,    1,    1,    1,    1,
  1156. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1157. X        1,    2,    4,    1,    5,    6,    1,    7,    1,    8,
  1158. X        9,   10,   11,   12,   13,   14,   15,   16,   17,   17,
  1159. X       17,   17,   17,   17,   17,   17,   18,    1,   12,    7,
  1160. X        7,    7,    4,   19,   20,   20,   20,   20,   20,   20,
  1161. X       20,   20,   20,   20,   20,   20,   20,   20,   21,   20,
  1162. X       20,   20,   20,   20,   20,   20,   20,   22,   20,   20,
  1163. X       23,    7,   24,   25,    7,    1,   26,   26,   27,   26,
  1164. X
  1165. X       28,   26,   26,   26,   26,   26,   26,   26,   26,   26,
  1166. X       29,   30,   26,   26,   26,   31,   26,   26,   26,   32,
  1167. X       26,   26,   33,    7,   34,    7,    1
  1168. X    } ;
  1169. X
  1170. Xstatic const YY_CHAR yy_meta[35] =
  1171. X    {   0,
  1172. X        1,    1,    1,    1,    2,    1,    2,    1,    1,    2,
  1173. X        2,    1,    3,    1,    2,    1,    4,    1,    1,    1,
  1174. X        1,    5,    1,    1,    6,    7,    7,    7,    7,    7,
  1175. X        7,    7,    1,    1
  1176. X    } ;
  1177. X
  1178. Xstatic const short int yy_base[88] =
  1179. X    {   0,
  1180. X        0,    0,  148,  225,  225,  225,   31,   41,    0,    0,
  1181. X       48,  225,   48,   68,   23,  119,   37,   85,   70,   36,
  1182. X       77,  105,  125,   78,  225,  225,  225,    0,    0,    0,
  1183. X      225,  134,  121,  119,  109,  129,  225,  146,   47,  152,
  1184. X      225,   63,  107,    0,    0,  145,  156,  101,  225,  106,
  1185. X      104,   78,   88,   26,   90,   74,  163,  225,    0,  225,
  1186. X      225,  225,  225,  162,   54,  225,  225,  173,  166,   76,
  1187. X      225,   73,  225,   38,  225,  225,  225,  225,  225,   48,
  1188. X      201,  202,  207,  212,  218,   42,   31
  1189. X    } ;
  1190. X
  1191. Xstatic const short int yy_def[88] =
  1192. X    {   0,
  1193. X       79,    1,   79,   79,   79,   79,   79,   79,   80,   81,
  1194. X       79,   79,    8,   79,   79,   82,   83,   79,   83,   79,
  1195. X       84,   79,   79,   84,   79,   79,   79,   85,   85,   86,
  1196. X       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
  1197. X       79,   82,   84,   24,   24,   43,   24,   79,   79,   24,
  1198. X       43,   79,   79,   79,   79,   79,   79,   79,   87,   79,
  1199. X       79,   79,   79,   79,   79,   79,   79,   79,   43,   79,
  1200. X       79,   79,   79,   79,   79,   79,   79,   79,    0,   79,
  1201. X       79,   79,   79,   79,   79,   79,   79
  1202. X    } ;
  1203. X
  1204. Xstatic const short int yy_nxt[260] =
  1205. X    {   0,
  1206. X        4,    5,    6,    7,    8,    9,   10,   11,    4,   10,
  1207. X        8,   12,   13,   12,   10,   14,   15,   15,   16,   17,
  1208. X       18,   19,   20,    4,   10,   21,   21,   22,   23,   21,
  1209. X       21,   24,   25,   26,   27,   27,   37,   76,   39,   39,
  1210. X       39,   27,   63,   27,   27,   28,   48,   29,   59,   43,
  1211. X       29,   28,   73,   28,   30,   29,   31,   32,   43,   49,
  1212. X       37,   33,   39,   39,   39,   29,   78,   37,   45,   39,
  1213. X       39,   39,   34,   35,   35,   35,   35,   35,   35,   35,
  1214. X       36,   37,   43,   38,   39,   39,   77,   79,   40,   43,
  1215. X       43,   43,   63,   50,   50,   67,   40,   46,   43,   43,
  1216. X
  1217. X       40,   45,   75,   74,   63,   40,   43,   72,   51,   51,
  1218. X       44,   44,   44,   47,   44,   44,   45,   43,   52,   79,
  1219. X       63,   50,   79,   79,   71,   63,   43,   62,   79,   61,
  1220. X       35,   35,   35,   35,   53,   54,   51,   46,   55,   56,
  1221. X       40,   50,   60,   41,   40,   40,   43,   79,   79,   40,
  1222. X       35,   35,   35,   57,   35,   35,   51,   40,   64,   37,
  1223. X       40,   65,   39,   39,   64,   40,   66,   66,   69,   79,
  1224. X       79,   66,   66,   68,   66,   64,   66,   66,   66,   63,
  1225. X       66,   66,   66,   66,   70,   64,   66,   79,   66,   63,
  1226. X       66,   66,   79,   66,   70,   79,   79,   79,   79,   79,
  1227. X
  1228. X       79,   66,   29,   29,   79,   79,   29,   42,   42,   44,
  1229. X       79,   44,   79,   44,   35,   35,   35,   79,   35,   58,
  1230. X       58,   79,   79,   58,    3,   79,   79,   79,   79,   79,
  1231. X       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
  1232. X       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
  1233. X       79,   79,   79,   79,   79,   79,   79,   79,   79
  1234. X    } ;
  1235. X
  1236. Xstatic const short int yy_chk[260] =
  1237. X    {   0,
  1238. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1239. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1240. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1241. X        1,    1,    1,    1,    7,    7,   15,   87,   15,   15,
  1242. X       15,    7,   54,    7,    8,    8,   20,    8,   86,   17,
  1243. X        8,    8,   54,    8,   80,    8,   11,   11,   17,   20,
  1244. X       39,   11,   39,   39,   39,    8,   74,   65,   17,   65,
  1245. X       65,   65,   11,   13,   13,   13,   13,   13,   13,   13,
  1246. X       14,   14,   19,   14,   14,   14,   72,   42,   14,   21,
  1247. X       24,   19,   70,   21,   24,   42,   14,   18,   21,   24,
  1248. X
  1249. X       18,   19,   56,   55,   53,   18,   18,   52,   21,   24,
  1250. X       18,   18,   18,   18,   18,   18,   18,   22,   22,   43,
  1251. X       51,   22,   50,   43,   48,   35,   22,   34,   43,   33,
  1252. X       22,   22,   22,   22,   22,   22,   22,   23,   23,   23,
  1253. X       23,   23,   32,   16,   36,   23,   23,    3,    0,   36,
  1254. X       23,   23,   23,   23,   23,   23,   23,   36,   38,   38,
  1255. X       46,   38,   38,   38,   40,   46,   38,   40,   47,    0,
  1256. X        0,   47,   40,   46,   38,   57,   47,   64,   57,   57,
  1257. X       40,   69,   64,   57,   47,   68,   69,    0,   68,   68,
  1258. X       64,   57,    0,   68,   69,    0,    0,    0,    0,    0,
  1259. X
  1260. X        0,   68,   81,   81,    0,    0,   81,   82,   82,   83,
  1261. X        0,   83,    0,   83,   84,   84,   84,    0,   84,   85,
  1262. X       85,    0,    0,   85,   79,   79,   79,   79,   79,   79,
  1263. X       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
  1264. X       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
  1265. X       79,   79,   79,   79,   79,   79,   79,   79,   79
  1266. X    } ;
  1267. X
  1268. Xstatic yy_state_type yy_last_accepting_state;
  1269. Xstatic YY_CHAR *yy_last_accepting_cpos;
  1270. X
  1271. X/* the intent behind this definition is that it'll catch
  1272. X * any uses of REJECT which flex missed
  1273. X */
  1274. X#define REJECT reject_used_but_not_detected
  1275. X#define yymore() yymore_used_but_not_detected
  1276. X#define YY_MORE_ADJ 0
  1277. X
  1278. X/* these variables are all declared out here so that section 3 code can
  1279. X * manipulate them
  1280. X */
  1281. X/* points to current character in buffer */
  1282. Xstatic YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  1283. Xstatic int yy_init = 1;        /* whether we need to initialize */
  1284. Xstatic int yy_start = 0;    /* start state number */
  1285. X
  1286. X/* flag which is used to allow yywrap()'s to do buffer switches
  1287. X * instead of setting up a fresh yyin.  A bit of a hack ...
  1288. X */
  1289. Xstatic int yy_did_buffer_switch_on_eof;
  1290. X
  1291. Xstatic yy_state_type yy_get_previous_state YY_PROTO(( void ));
  1292. Xstatic yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  1293. Xstatic int yy_get_next_buffer YY_PROTO(( void ));
  1294. Xstatic void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  1295. Xvoid yyrestart YY_PROTO(( FILE *input_file ));
  1296. Xvoid yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  1297. Xvoid yy_load_buffer_state YY_PROTO(( void ));
  1298. XYY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  1299. Xvoid yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  1300. Xvoid yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  1301. X
  1302. X#define yy_new_buffer yy_create_buffer
  1303. X
  1304. X#ifdef __cplusplus
  1305. Xstatic int yyinput YY_PROTO(( void ));
  1306. X#else
  1307. Xstatic int input YY_PROTO(( void ));
  1308. X#endif
  1309. X
  1310. XYY_DECL
  1311. X    {
  1312. X    register yy_state_type yy_current_state;
  1313. X    register YY_CHAR *yy_cp, *yy_bp;
  1314. X    register int yy_act;
  1315. X
  1316. X
  1317. X
  1318. X    if ( yy_init )
  1319. X    {
  1320. X    YY_USER_INIT;
  1321. X
  1322. X    if ( ! yy_start )
  1323. X        yy_start = 1;    /* first start state */
  1324. X
  1325. X    if ( ! yyin )
  1326. X        yyin = stdin;
  1327. X
  1328. X    if ( ! yyout )
  1329. X        yyout = stdout;
  1330. X
  1331. X    if ( yy_current_buffer )
  1332. X        yy_init_buffer( yy_current_buffer, yyin );
  1333. X    else
  1334. X        yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  1335. X
  1336. X    yy_load_buffer_state();
  1337. X
  1338. X    yy_init = 0;
  1339. X    }
  1340. X
  1341. X    while ( 1 )        /* loops until end-of-file is reached */
  1342. X    {
  1343. X    yy_cp = yy_c_buf_p;
  1344. X
  1345. X    /* support of yytext */
  1346. X    *yy_cp = yy_hold_char;
  1347. X
  1348. X    /* yy_bp points to the position in yy_ch_buf of the start of the
  1349. X     * current run.
  1350. X     */
  1351. X    yy_bp = yy_cp;
  1352. X
  1353. X    yy_current_state = yy_start;
  1354. Xyy_match:
  1355. X    do
  1356. X        {
  1357. X        register YY_CHAR yy_c = yy_ec[*yy_cp];
  1358. X        if ( yy_accept[yy_current_state] )
  1359. X        {
  1360. X        yy_last_accepting_state = yy_current_state;
  1361. X        yy_last_accepting_cpos = yy_cp;
  1362. X        }
  1363. X        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1364. X        {
  1365. X        yy_current_state = yy_def[yy_current_state];
  1366. X        if ( yy_current_state >= 80 )
  1367. X            yy_c = yy_meta[yy_c];
  1368. X        }
  1369. X        yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1370. X        ++yy_cp;
  1371. X        }
  1372. X    while ( yy_current_state != 79 );
  1373. X    yy_cp = yy_last_accepting_cpos;
  1374. X    yy_current_state = yy_last_accepting_state;
  1375. X
  1376. Xyy_find_action:
  1377. X    yy_act = yy_accept[yy_current_state];
  1378. X
  1379. X    YY_DO_BEFORE_ACTION;
  1380. X    YY_USER_ACTION;
  1381. X
  1382. Xdo_action:    /* this label is used only to access EOF actions */
  1383. X
  1384. X
  1385. X    switch ( yy_act )
  1386. X        {
  1387. X        case 0: /* must backtrack */
  1388. X        /* undo the effects of YY_DO_BEFORE_ACTION */
  1389. X        *yy_cp = yy_hold_char;
  1390. X        yy_cp = yy_last_accepting_cpos;
  1391. X        yy_current_state = yy_last_accepting_state;
  1392. X        goto yy_find_action;
  1393. X
  1394. Xcase 1:
  1395. X# line 35 "lexer.l"
  1396. X{ /* roque */ ; parse_roque(yytext); }
  1397. X    YY_BREAK
  1398. Xcase 2:
  1399. X# line 36 "lexer.l"
  1400. X{ /* move number */ parse_number(yytext); }
  1401. X    YY_BREAK
  1402. Xcase 3:
  1403. X# line 37 "lexer.l"
  1404. X{ /* move */  
  1405. X  (void) parse_move(yytext);
  1406. X  /*; fprintf(stderr,"%s, ",yytext);*/ 
  1407. X}
  1408. X    YY_BREAK
  1409. Xcase 4:
  1410. X# line 43 "lexer.l"
  1411. X{ /* comment */ ; 
  1412. X                parse_comment(yytext); }
  1413. X    YY_BREAK
  1414. Xcase 5:
  1415. X# line 45 "lexer.l"
  1416. X{ /* comment */ ; 
  1417. X                   parse_comment(yytext); }
  1418. X    YY_BREAK
  1419. Xcase 6:
  1420. X# line 47 "lexer.l"
  1421. X{ /* comment */ ; 
  1422. X                     parse_comment(yytext); }
  1423. X    YY_BREAK
  1424. Xcase 7:
  1425. X# line 49 "lexer.l"
  1426. X{ /* comment */ ; 
  1427. X               parse_comment(yytext); }
  1428. X    YY_BREAK
  1429. Xcase 8:
  1430. X# line 51 "lexer.l"
  1431. X{ /* comment */ ; parse_comment(yytext); }
  1432. X    YY_BREAK
  1433. Xcase 9:
  1434. X# line 52 "lexer.l"
  1435. X{ /* comment */ ; parse_comment(yytext); }
  1436. X    YY_BREAK
  1437. Xcase 10:
  1438. X# line 53 "lexer.l"
  1439. X{ /* comment */ ; parse_comment(yytext); }
  1440. X    YY_BREAK
  1441. Xcase 11:
  1442. X# line 54 "lexer.l"
  1443. X{ /* comment */ ; parse_comment(yytext); }
  1444. X    YY_BREAK
  1445. Xcase 12:
  1446. X# line 55 "lexer.l"
  1447. X{ /* comment */ ; parse_comment(yytext); }
  1448. X    YY_BREAK
  1449. Xcase 13:
  1450. X# line 56 "lexer.l"
  1451. X{ /* comment */ ; parse_comment(yytext); }
  1452. X    YY_BREAK
  1453. Xcase 14:
  1454. X# line 57 "lexer.l"
  1455. X{ /* comment */ ; parse_comment(yytext); }
  1456. X    YY_BREAK
  1457. Xcase 15:
  1458. X# line 58 "lexer.l"
  1459. X{ /* comment */ ; parse_comment(yytext); }
  1460. X    YY_BREAK
  1461. Xcase 16:
  1462. X# line 59 "lexer.l"
  1463. X{ /* comment */ ; parse_comment(yytext); }
  1464. X    YY_BREAK
  1465. Xcase 17:
  1466. X# line 60 "lexer.l"
  1467. X{ /* comment */ ; parse_comment(yytext); }
  1468. X    YY_BREAK
  1469. Xcase 18:
  1470. X# line 61 "lexer.l"
  1471. X{ /* comment */ ; parse_comment(yytext); }
  1472. X    YY_BREAK
  1473. Xcase 19:
  1474. X# line 62 "lexer.l"
  1475. X{ /* comment */ ; parse_comment("etc"); }
  1476. X    YY_BREAK
  1477. Xcase 20:
  1478. X# line 63 "lexer.l"
  1479. X{ /* comment */ ; parse_comment("ep"); }
  1480. X    YY_BREAK
  1481. Xcase 21:
  1482. X# line 64 "lexer.l"
  1483. X{ /* game comment */ ; parse_comment(yytext); }
  1484. X    YY_BREAK
  1485. Xcase 22:
  1486. X# line 65 "lexer.l"
  1487. X{ /* keyword with arg */ 
  1488. X  yytext[yyleng -1] = '\0' ;
  1489. X  parse_keyword(yytext, comment('}'));
  1490. X}
  1491. X    YY_BREAK
  1492. Xcase 23:
  1493. X# line 69 "lexer.l"
  1494. X{ /* keyword without arg */ 
  1495. X  parse_keyword(yytext,NULL); }
  1496. X    YY_BREAK
  1497. Xcase 24:
  1498. X# line 71 "lexer.l"
  1499. X{ parse_text(comment(']')); }
  1500. X    YY_BREAK
  1501. Xcase 25:
  1502. X# line 72 "lexer.l"
  1503. X{ parse_text(comment(')')); }
  1504. X    YY_BREAK
  1505. Xcase 26:
  1506. X# line 73 "lexer.l"
  1507. X{ /* enter variation */ ; enter_variation(); }
  1508. X    YY_BREAK
  1509. Xcase 27:
  1510. X# line 74 "lexer.l"
  1511. X{ /* close variation */ ; exit_variation(); }
  1512. X    YY_BREAK
  1513. Xcase 28:
  1514. X# line 75 "lexer.l"
  1515. X{ /* skip , ; */ ; }
  1516. X    YY_BREAK
  1517. Xcase 29:
  1518. X# line 76 "lexer.l"
  1519. X{ /* skip blanks */; }
  1520. X    YY_BREAK
  1521. Xcase 30:
  1522. X# line 77 "lexer.l"
  1523. X{ /* ignore bad characters */ (void) fprintf(stderr,"I don't understand: %s\n",yytext);}
  1524. X    YY_BREAK
  1525. Xcase 31:
  1526. X# line 78 "lexer.l"
  1527. XECHO;
  1528. X    YY_BREAK
  1529. Xcase YY_STATE_EOF(INITIAL):
  1530. X    yyterminate();
  1531. X
  1532. X        case YY_END_OF_BUFFER:
  1533. X        {
  1534. X        /* amount of text matched not including the EOB char */
  1535. X        int yy_amount_of_matched_text = yy_cp - yytext - 1;
  1536. X
  1537. X        /* undo the effects of YY_DO_BEFORE_ACTION */
  1538. X        *yy_cp = yy_hold_char;
  1539. X
  1540. X        /* note that here we test for yy_c_buf_p "<=" to the position
  1541. X         * of the first EOB in the buffer, since yy_c_buf_p will
  1542. X         * already have been incremented past the NUL character
  1543. X         * (since all states make transitions on EOB to the end-
  1544. X         * of-buffer state).  Contrast this with the test in yyinput().
  1545. X         */
  1546. X        if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1547. X            /* this was really a NUL */
  1548. X            {
  1549. X            yy_state_type yy_next_state;
  1550. X
  1551. X            yy_c_buf_p = yytext + yy_amount_of_matched_text;
  1552. X
  1553. X            yy_current_state = yy_get_previous_state();
  1554. X
  1555. X            /* okay, we're now positioned to make the
  1556. X             * NUL transition.  We couldn't have
  1557. X             * yy_get_previous_state() go ahead and do it
  1558. X             * for us because it doesn't know how to deal
  1559. X             * with the possibility of jamming (and we
  1560. X             * don't want to build jamming into it because
  1561. X             * then it will run more slowly)
  1562. X             */
  1563. X
  1564. X            yy_next_state = yy_try_NUL_trans( yy_current_state );
  1565. X
  1566. X            yy_bp = yytext + YY_MORE_ADJ;
  1567. X
  1568. X            if ( yy_next_state )
  1569. X            {
  1570. X            /* consume the NUL */
  1571. X            yy_cp = ++yy_c_buf_p;
  1572. X            yy_current_state = yy_next_state;
  1573. X            goto yy_match;
  1574. X            }
  1575. X
  1576. X            else
  1577. X            {
  1578. X                yy_cp = yy_last_accepting_cpos;
  1579. X                yy_current_state = yy_last_accepting_state;
  1580. X            goto yy_find_action;
  1581. X            }
  1582. X            }
  1583. X
  1584. X        else switch ( yy_get_next_buffer() )
  1585. X            {
  1586. X            case EOB_ACT_END_OF_FILE:
  1587. X            {
  1588. X            yy_did_buffer_switch_on_eof = 0;
  1589. X
  1590. X            if ( yywrap() )
  1591. X                {
  1592. X                /* note: because we've taken care in
  1593. X                 * yy_get_next_buffer() to have set up yytext,
  1594. X                 * we can now set up yy_c_buf_p so that if some
  1595. X                 * total hoser (like flex itself) wants
  1596. X                 * to call the scanner after we return the
  1597. X                 * YY_NULL, it'll still work - another YY_NULL
  1598. X                 * will get returned.
  1599. X                 */
  1600. X                yy_c_buf_p = yytext + YY_MORE_ADJ;
  1601. X
  1602. X                yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  1603. X                goto do_action;
  1604. X                }
  1605. X
  1606. X            else
  1607. X                {
  1608. X                if ( ! yy_did_buffer_switch_on_eof )
  1609. X                YY_NEW_FILE;
  1610. X                }
  1611. X            }
  1612. X            break;
  1613. X
  1614. X            case EOB_ACT_CONTINUE_SCAN:
  1615. X            yy_c_buf_p = yytext + yy_amount_of_matched_text;
  1616. X
  1617. X            yy_current_state = yy_get_previous_state();
  1618. X
  1619. X            yy_cp = yy_c_buf_p;
  1620. X            yy_bp = yytext + YY_MORE_ADJ;
  1621. X            goto yy_match;
  1622. X
  1623. X            case EOB_ACT_LAST_MATCH:
  1624. X            yy_c_buf_p =
  1625. X                &yy_current_buffer->yy_ch_buf[yy_n_chars];
  1626. X
  1627. X            yy_current_state = yy_get_previous_state();
  1628. X
  1629. X            yy_cp = yy_c_buf_p;
  1630. X            yy_bp = yytext + YY_MORE_ADJ;
  1631. X            goto yy_find_action;
  1632. X            }
  1633. X        break;
  1634. X        }
  1635. X
  1636. X        default:
  1637. X#ifdef FLEX_DEBUG
  1638. X        printf( "action # %d\n", yy_act );
  1639. X#endif
  1640. X        YY_FATAL_ERROR(
  1641. X            "fatal flex scanner internal error--no action found" );
  1642. X        }
  1643. X    }
  1644. X    }
  1645. X
  1646. X
  1647. X/* yy_get_next_buffer - try to read in a new buffer
  1648. X *
  1649. X * synopsis
  1650. X *     int yy_get_next_buffer();
  1651. X *     
  1652. X * returns a code representing an action
  1653. X *     EOB_ACT_LAST_MATCH - 
  1654. X *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1655. X *     EOB_ACT_END_OF_FILE - end of file
  1656. X */
  1657. X
  1658. Xstatic int yy_get_next_buffer()
  1659. X
  1660. X    {
  1661. X    register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  1662. X    register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  1663. X    register int number_to_move, i;
  1664. X    int ret_val;
  1665. X
  1666. X    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  1667. X    YY_FATAL_ERROR(
  1668. X        "fatal flex scanner internal error--end of buffer missed" );
  1669. X
  1670. X    /* try to read more data */
  1671. X
  1672. X    /* first move last chars to start of buffer */
  1673. X    number_to_move = yy_c_buf_p - yytext;
  1674. X
  1675. X    for ( i = 0; i < number_to_move; ++i )
  1676. X    *(dest++) = *(source++);
  1677. X
  1678. X    if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  1679. X    /* don't do the read, it's not guaranteed to return an EOF,
  1680. X     * just force an EOF
  1681. X     */
  1682. X    yy_n_chars = 0;
  1683. X
  1684. X    else
  1685. X    {
  1686. X    int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  1687. X
  1688. X    if ( num_to_read > YY_READ_BUF_SIZE )
  1689. X        num_to_read = YY_READ_BUF_SIZE;
  1690. X
  1691. X    else if ( num_to_read <= 0 )
  1692. X        YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  1693. X
  1694. X    /* read in more data */
  1695. X    YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  1696. X          yy_n_chars, num_to_read );
  1697. X    }
  1698. X
  1699. X    if ( yy_n_chars == 0 )
  1700. X    {
  1701. X    if ( number_to_move == 1 )
  1702. X        {
  1703. X        ret_val = EOB_ACT_END_OF_FILE;
  1704. X        yy_current_buffer->yy_eof_status = EOF_DONE;
  1705. X        }
  1706. X
  1707. X    else
  1708. X        {
  1709. X        ret_val = EOB_ACT_LAST_MATCH;
  1710. X        yy_current_buffer->yy_eof_status = EOF_PENDING;
  1711. X        }
  1712. X    }
  1713. X
  1714. X    else
  1715. X    ret_val = EOB_ACT_CONTINUE_SCAN;
  1716. X
  1717. X    yy_n_chars += number_to_move;
  1718. X    yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  1719. X    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  1720. X
  1721. X    /* yytext begins at the second character in yy_ch_buf; the first
  1722. X     * character is the one which preceded it before reading in the latest
  1723. X     * buffer; it needs to be kept around in case it's a newline, so
  1724. X     * yy_get_previous_state() will have with '^' rules active
  1725. X     */
  1726. X
  1727. X    yytext = &yy_current_buffer->yy_ch_buf[1];
  1728. X
  1729. X    return ( ret_val );
  1730. X    }
  1731. X
  1732. X
  1733. X/* yy_get_previous_state - get the state just before the EOB char was reached
  1734. X *
  1735. X * synopsis
  1736. X *     yy_state_type yy_get_previous_state();
  1737. X */
  1738. X
  1739. Xstatic yy_state_type yy_get_previous_state()
  1740. X
  1741. X    {
  1742. X    register yy_state_type yy_current_state;
  1743. X    register YY_CHAR *yy_cp;
  1744. X
  1745. X    yy_current_state = yy_start;
  1746. X
  1747. X    for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  1748. X    {
  1749. X    register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  1750. X    if ( yy_accept[yy_current_state] )
  1751. X        {
  1752. X        yy_last_accepting_state = yy_current_state;
  1753. X        yy_last_accepting_cpos = yy_cp;
  1754. X        }
  1755. X    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1756. X        {
  1757. X        yy_current_state = yy_def[yy_current_state];
  1758. X        if ( yy_current_state >= 80 )
  1759. X        yy_c = yy_meta[yy_c];
  1760. X        }
  1761. X    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1762. X    }
  1763. X
  1764. X    return ( yy_current_state );
  1765. X    }
  1766. X
  1767. X
  1768. X/* yy_try_NUL_trans - try to make a transition on the NUL character
  1769. X *
  1770. X * synopsis
  1771. X *     next_state = yy_try_NUL_trans( current_state );
  1772. X */
  1773. X
  1774. X#ifdef YY_USE_PROTOS
  1775. Xstatic yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  1776. X#else
  1777. Xstatic yy_state_type yy_try_NUL_trans( yy_current_state )
  1778. Xregister yy_state_type yy_current_state;
  1779. X#endif
  1780. X
  1781. X    {
  1782. X    register int yy_is_jam;
  1783. X    register YY_CHAR *yy_cp = yy_c_buf_p;
  1784. X
  1785. X    register YY_CHAR yy_c = 1;
  1786. X    if ( yy_accept[yy_current_state] )
  1787. X    {
  1788. X    yy_last_accepting_state = yy_current_state;
  1789. X    yy_last_accepting_cpos = yy_cp;
  1790. X    }
  1791. X    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1792. X    {
  1793. X    yy_current_state = yy_def[yy_current_state];
  1794. X    if ( yy_current_state >= 80 )
  1795. X        yy_c = yy_meta[yy_c];
  1796. X    }
  1797. X    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1798. X    yy_is_jam = (yy_current_state == 79);
  1799. X
  1800. X    return ( yy_is_jam ? 0 : yy_current_state );
  1801. X    }
  1802. X
  1803. X
  1804. X#ifdef YY_USE_PROTOS
  1805. Xstatic void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  1806. X#else
  1807. Xstatic void yyunput( c, yy_bp )
  1808. XYY_CHAR c;
  1809. Xregister YY_CHAR *yy_bp;
  1810. X#endif
  1811. X
  1812. X    {
  1813. X    register YY_CHAR *yy_cp = yy_c_buf_p;
  1814. X
  1815. X    /* undo effects of setting up yytext */
  1816. X    *yy_cp = yy_hold_char;
  1817. X
  1818. X    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1819. X    { /* need to shift things up to make room */
  1820. X    register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  1821. X    register YY_CHAR *dest =
  1822. X        &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  1823. X    register YY_CHAR *source =
  1824. X        &yy_current_buffer->yy_ch_buf[number_to_move];
  1825. X
  1826. X    while ( source > yy_current_buffer->yy_ch_buf )
  1827. X        *--dest = *--source;
  1828. X
  1829. X    yy_cp += dest - source;
  1830. X    yy_bp += dest - source;
  1831. X    yy_n_chars = yy_current_buffer->yy_buf_size;
  1832. X
  1833. X    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1834. X        YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1835. X    }
  1836. X
  1837. X    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  1838. X    yy_cp[-2] = '\n';
  1839. X
  1840. X    *--yy_cp = c;
  1841. X
  1842. X    /* note: the formal parameter *must* be called "yy_bp" for this
  1843. X     *       macro to now work correctly
  1844. X     */
  1845. X    YY_DO_BEFORE_ACTION; /* set up yytext again */
  1846. X    }
  1847. X
  1848. X
  1849. X#ifdef __cplusplus
  1850. Xstatic int yyinput()
  1851. X#else
  1852. Xstatic int input()
  1853. X#endif
  1854. X
  1855. X    {
  1856. X    int c;
  1857. X    YY_CHAR *yy_cp = yy_c_buf_p;
  1858. X
  1859. X    *yy_cp = yy_hold_char;
  1860. X
  1861. X    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1862. X    {
  1863. X    /* yy_c_buf_p now points to the character we want to return.
  1864. X     * If this occurs *before* the EOB characters, then it's a
  1865. X     * valid NUL; if not, then we've hit the end of the buffer.
  1866. X     */
  1867. X    if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1868. X        /* this was really a NUL */
  1869. X        *yy_c_buf_p = '\0';
  1870. X
  1871. X    else
  1872. X        { /* need more input */
  1873. X        yytext = yy_c_buf_p;
  1874. X        ++yy_c_buf_p;
  1875. X
  1876. X        switch ( yy_get_next_buffer() )
  1877. X        {
  1878. X        case EOB_ACT_END_OF_FILE:
  1879. X            {
  1880. X            if ( yywrap() )
  1881. X            {
  1882. X            yy_c_buf_p = yytext + YY_MORE_ADJ;
  1883. X            return ( EOF );
  1884. X            }
  1885. X
  1886. X            YY_NEW_FILE;
  1887. X
  1888. X#ifdef __cplusplus
  1889. X            return ( yyinput() );
  1890. X#else
  1891. X            return ( input() );
  1892. X#endif
  1893. X            }
  1894. X            break;
  1895. X
  1896. X        case EOB_ACT_CONTINUE_SCAN:
  1897. X            yy_c_buf_p = yytext + YY_MORE_ADJ;
  1898. X            break;
  1899. X
  1900. X        case EOB_ACT_LAST_MATCH:
  1901. X#ifdef __cplusplus
  1902. X            YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  1903. X#else
  1904. X            YY_FATAL_ERROR( "unexpected last match in input()" );
  1905. X#endif
  1906. X        }
  1907. X        }
  1908. X    }
  1909. X
  1910. X    c = *yy_c_buf_p;
  1911. X    yy_hold_char = *++yy_c_buf_p;
  1912. X
  1913. X    return ( c );
  1914. X    }
  1915. X
  1916. X
  1917. X#ifdef YY_USE_PROTOS
  1918. Xvoid yyrestart( FILE *input_file )
  1919. X#else
  1920. Xvoid yyrestart( input_file )
  1921. XFILE *input_file;
  1922. X#endif
  1923. X
  1924. X    {
  1925. X    yy_init_buffer( yy_current_buffer, input_file );
  1926. X    yy_load_buffer_state();
  1927. X    }
  1928. X
  1929. X
  1930. X#ifdef YY_USE_PROTOS
  1931. Xvoid yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1932. X#else
  1933. Xvoid yy_switch_to_buffer( new_buffer )
  1934. XYY_BUFFER_STATE new_buffer;
  1935. X#endif
  1936. X
  1937. X    {
  1938. X    if ( yy_current_buffer == new_buffer )
  1939. X    return;
  1940. X
  1941. X    if ( yy_current_buffer )
  1942. X    {
  1943. X    /* flush out information for old buffer */
  1944. X    *yy_c_buf_p = yy_hold_char;
  1945. X    yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1946. X    yy_current_buffer->yy_n_chars = yy_n_chars;
  1947. X    }
  1948. X
  1949. X    yy_current_buffer = new_buffer;
  1950. X    yy_load_buffer_state();
  1951. X
  1952. X    /* we don't actually know whether we did this switch during
  1953. X     * EOF (yywrap()) processing, but the only time this flag
  1954. X     * is looked at is after yywrap() is called, so it's safe
  1955. X     * to go ahead and always set it.
  1956. X     */
  1957. X    yy_did_buffer_switch_on_eof = 1;
  1958. X    }
  1959. X
  1960. X
  1961. X#ifdef YY_USE_PROTOS
  1962. Xvoid yy_load_buffer_state( void )
  1963. X#else
  1964. Xvoid yy_load_buffer_state()
  1965. X#endif
  1966. X
  1967. X    {
  1968. X    yy_n_chars = yy_current_buffer->yy_n_chars;
  1969. X    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1970. X    yyin = yy_current_buffer->yy_input_file;
  1971. X    yy_hold_char = *yy_c_buf_p;
  1972. X    }
  1973. X
  1974. X
  1975. X#ifdef YY_USE_PROTOS
  1976. XYY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1977. X#else
  1978. XYY_BUFFER_STATE yy_create_buffer( file, size )
  1979. XFILE *file;
  1980. Xint size;
  1981. X#endif
  1982. X
  1983. X    {
  1984. X    YY_BUFFER_STATE b;
  1985. X
  1986. X    b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  1987. X
  1988. X    if ( ! b )
  1989. X    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1990. X
  1991. X    b->yy_buf_size = size;
  1992. X
  1993. X    /* yy_ch_buf has to be 2 characters longer than the size given because
  1994. X     * we need to put in 2 end-of-buffer characters.
  1995. X     */
  1996. X    b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  1997. X
  1998. X    if ( ! b->yy_ch_buf )
  1999. X    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  2000. X
  2001. X    yy_init_buffer( b, file );
  2002. X
  2003. X    return ( b );
  2004. X    }
  2005. X
  2006. X
  2007. X#ifdef YY_USE_PROTOS
  2008. Xvoid yy_delete_buffer( YY_BUFFER_STATE b )
  2009. X#else
  2010. Xvoid yy_delete_buffer( b )
  2011. XYY_BUFFER_STATE b;
  2012. X#endif
  2013. X
  2014. X    {
  2015. X    if ( b == yy_current_buffer )
  2016. X    yy_current_buffer = (YY_BUFFER_STATE) 0;
  2017. X
  2018. X    free( (char *) b->yy_ch_buf );
  2019. X    free( (char *) b );
  2020. X    }
  2021. X
  2022. X
  2023. X#ifdef YY_USE_PROTOS
  2024. Xvoid yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  2025. X#else
  2026. Xvoid yy_init_buffer( b, file )
  2027. XYY_BUFFER_STATE b;
  2028. XFILE *file;
  2029. X#endif
  2030. X
  2031. X    {
  2032. X    b->yy_input_file = file;
  2033. X
  2034. X    /* we put in the '\n' and start reading from [1] so that an
  2035. X     * initial match-at-newline will be true.
  2036. X     */
  2037. X
  2038. X    b->yy_ch_buf[0] = '\n';
  2039. X    b->yy_n_chars = 1;
  2040. X
  2041. X    /* we always need two end-of-buffer characters.  The first causes
  2042. X     * a transition to the end-of-buffer state.  The second causes
  2043. X     * a jam in that state.
  2044. X     */
  2045. X    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  2046. X    b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  2047. X
  2048. X    b->yy_buf_pos = &b->yy_ch_buf[1];
  2049. X
  2050. X    b->yy_eof_status = EOF_NOT_SEEN;
  2051. X    }
  2052. X# line 78 "lexer.l"
  2053. X
  2054. X
  2055. X#ifdef FLEX_SCANNER
  2056. X#undef yywrap
  2057. X#endif
  2058. X#ifdef __STDC__
  2059. Xint yywrap(void)
  2060. X#else
  2061. Xint yywrap()
  2062. X#endif
  2063. X{
  2064. X        return(1);
  2065. X}
  2066. X
  2067. X
  2068. X/* this procedure store comments in the text array commbuf
  2069. X   Escape char are allowed for putting the end-of-comment symbol
  2070. X   in the buffer
  2071. X   */
  2072. X#ifdef __STDC__
  2073. Xstatic char * comment(int closing)
  2074. X#else
  2075. Xstatic char * comment(closing)
  2076. X     char closing;
  2077. X#endif
  2078. X{
  2079. X  register char c;
  2080. X  register int i=0;
  2081. X
  2082. X  while ( ((c = input()) != closing)  && (c != 0) && (c != EOF)) {
  2083. X    commbuf[i] = c;
  2084. X    if (i <LARGE_BUF) i++ ;
  2085. X    
  2086. X    if (c == '\\') {
  2087. X      c = input() ;
  2088. X      if (c == closing)
  2089. X    commbuf[i-1] = c;
  2090. X      else
  2091. X    unput(c);
  2092. X    }
  2093. X  }
  2094. X  commbuf[i] = '\0' ;
  2095. X  return(commbuf);
  2096. X}
  2097. X
  2098. X#ifdef __STDC__
  2099. Xstatic void count(void)
  2100. X#else
  2101. Xstatic void count()
  2102. X#endif
  2103. X{
  2104. X  register int i;
  2105. X  register int k;
  2106. X
  2107. X  for (i = 0; yytext[i] != '\0'; i++) {
  2108. X    if (yytext[i] == '\n') {
  2109. X      column = 0;
  2110. X      for (k = 0 ; k< NCURLINE; k++) /*PANDORE*/
  2111. X        curline[k] = ' '; /*PANDORE*/
  2112. X      lineno++;
  2113. X    }
  2114. X    else if (yytext[i] == '\t') {
  2115. X      column += 8 - (column % 8);
  2116. X      curline[column] = yytext[i];
  2117. X    } else {
  2118. X      column++;
  2119. X      curline[column] = yytext[i];
  2120. X    }
  2121. X    curline[column+1]= '\0' ;
  2122. X  }
  2123. X  /*ECHO;*/
  2124. X}
  2125. END_OF_FILE
  2126. if test 32637 -ne `wc -c <'lexer.c'`; then
  2127.     echo shar: \"'lexer.c'\" unpacked with wrong size!
  2128. fi
  2129. # end of 'lexer.c'
  2130. fi
  2131. echo shar: End of archive 3 \(of 4\).
  2132. cp /dev/null ark3isdone
  2133. MISSING=""
  2134. for I in 1 2 3 4 ; do
  2135.     if test ! -f ark${I}isdone ; then
  2136.     MISSING="${MISSING} ${I}"
  2137.     fi
  2138. done
  2139. if test "${MISSING}" = "" ; then
  2140.     echo You have unpacked all 4 archives.
  2141.     rm -f ark[1-9]isdone
  2142. else
  2143.     echo You still need to unpack the following archives:
  2144.     echo "        " ${MISSING}
  2145. fi
  2146. ##  End of shell archive.
  2147. exit 0
  2148.  
  2149. --
  2150. Henry Thomas - IRISA          - E-mail: Henry.Thomas@irisa.fr 
  2151. Campus Universitaire de Beaulieu - Phone: (+33)99 36 20 00 +549  
  2152. 35042 RENNES CEDEX FRANCE      - Fax: (+33)99 38 38 32 Telex: UNIRISA 950473F
  2153. Telex Atlas X400: /X121=842950473/@atlas.fr, Fax:/X121=200099383832/@atlas.fr
  2154. --
  2155.  
  2156. exit 0 # Just in case...
  2157. -- 
  2158. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2159. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2160. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2161. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2162.